# from urllib.request import urlopen
# url = 'http://10.9.244.16:9033/task?page=1&size=10&product=VIPER'
# print(urlopen(url))#返回http.client.HTTPResponse object at 0x00000235BA25A160
# print("===================")
# print(urlopen(url).read().decode())#返回get到的页面的源代码
# decode是将base类型转为encoding 指定的编码格式解码字符串，不指定则转为默认编码，如utf-8


import tornado.ioloop
import tornado.web


class HelloHandler(tornado.web.RequestHandler):
    def get(self):
        """hello get请求"""
        self.write("Hello, world")

class StopHandler(tornado.web.RequestHandler):
    def get(self):
        """stop get请求"""
        tornado.ioloop.IOLoop.instance().StopIteration()

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        """get请求"""
        a = self.get_argument('a')
        b = self.get_argument('b')
        c  = int(a) + int(b)
        self.write("c=" + str(c))

application = tornado.web.Application([(r"/add", MainHandler), (r"/", HelloHandler), (r"/stop", StopHandler)])

if __name__ == "__main__":
    application.listen(8868)
    tornado.ioloop.IOLoop.instance().start()
    print("结束了")
